/* eslint-disable @typescript-eslint/no-explicit-any */
/*
 *  Copyright 2021 Collate
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

 /**
 * Create a SearchIndex entity request
 */
export interface CreateSearchIndex {
    /**
     * Fully qualified name of the domain the SearchIndex belongs to.
     */
    dataAssetDir?: string;
    /**
     * List of fully qualified names of data products this entity is part of.
     */
    dataProducts?: string[];
    /**
     * Description of the SearchIndex instance. What it has and how to use it.
     */
    description?: string;
    /**
     * Display Name that identifies this SearchIndex.
     */
    displayName?: string;
    /**
     * Fully qualified name of the domain the SearchIndex belongs to.
     */
    domain?: string;
    /**
     * Entity extension data with custom attributes added to the entity.
     */
    extension?: any;
    /**
     * Fields in this SearchIndex.
     */
    fields: SearchIndexField[];
    /**
     * Life Cycle of the entity
     */
    lifeCycle?: LifeCycle;
    /**
     * Name that identifies this SearchIndex instance uniquely.
     */
    name: string;
    /**
     * Owner of this SearchIndex
     */
    owner?: EntityReference;
    /**
     * Contains key/value pair of searchIndex settings.
     */
    searchIndexSettings?: { [key: string]: any };
    /**
     * Fully qualified name of the search service where this searchIndex is hosted in
     */
    service: string;
    /**
     * Source hash of the entity
     */
    sourceHash?: string;
    /**
     * Tags for this SearchIndex
     */
    tags?: CreateSearchIndexTag[];
}

/**
 * This schema defines the type for a field in a searchIndex.
 */
export interface SearchIndexField {
    /**
     * Child columns if dataType has properties.
     */
    children?: SearchIndexField[];
    /**
     * Data type of the searchIndex (int, date etc.).
     */
    dataType: DataType;
    /**
     * Display name used for dataType.
     */
    dataTypeDisplay?: string;
    /**
     * Description of the field.
     */
    description?: string;
    /**
     * Display Name that identifies this searchIndexField name.
     */
    displayName?:        string;
    fullyQualifiedName?: string;
    name:                string;
    /**
     * Tags associated with the column.
     */
    tags?: FieldTag[];
}

/**
 * Data type of the searchIndex (int, date etc.).
 *
 * This enum defines the type of data stored in a searchIndex.
 */
export enum DataType {
    AggregateMetricDouble = "AGGREGATE_METRIC_DOUBLE",
    AnnotatedText = "ANNOTATED-TEXT",
    Array = "ARRAY",
    Binary = "BINARY",
    Boolean = "BOOLEAN",
    Byte = "BYTE",
    Completion = "COMPLETION",
    ConstantKeyword = "CONSTANT_KEYWORD",
    Date = "DATE",
    Datetime = "DATETIME",
    DenseVector = "DENSE_VECTOR",
    Double = "DOUBLE",
    Flattened = "FLATTENED",
    Float = "FLOAT",
    GeoPoint = "GEO_POINT",
    GeoShape = "GEO_SHAPE",
    HalfFloat = "HALF_FLOAT",
    Histogram = "HISTOGRAM",
    IP = "IP",
    Integer = "INTEGER",
    Join = "JOIN",
    Keyword = "KEYWORD",
    Long = "LONG",
    Murmur3 = "MURMUR3",
    Nested = "NESTED",
    Number = "NUMBER",
    Object = "OBJECT",
    Percolator = "PERCOLATOR",
    Point = "POINT",
    Range = "RANGE",
    RankFeature = "RANK_FEATURE",
    RankFeatures = "RANK_FEATURES",
    ScaledFloat = "SCALED_FLOAT",
    SearchAsYouType = "SEARCH_AS_YOU_TYPE",
    Shape = "SHAPE",
    Short = "SHORT",
    Text = "TEXT",
    Time = "TIME",
    Timestamp = "TIMESTAMP",
    Timestampz = "TIMESTAMPZ",
    Unknown = "UNKNOWN",
    UnsignedLong = "UNSIGNED_LONG",
    Version = "VERSION",
    Wildcard = "WILDCARD",
}

/**
 * 此模式定义了用于使用标签标记实体的标签类型
 */
export interface FieldTag {
    /**
     * 标签标签的描述
     */
    description?: string;
    /**
     * 标识此标签的显示名称
     */
    displayName?: string;
    /**
     * 到标签资源的链接
     */
    href?: string;
    /**
     *
     * 标签类型描述标签标签是如何应用的，'Manual'表示标签标签是由人员应用的。'Derived'表示使用关联的标签关系导出了标签标签（有关详细信息，请参见Classification.json）。'Propagated`表示标签标签是根据血统从上游传播的。'Automated'在使用工具确定标签标签时使用。
     */
    labelType: LabelType;
    /**
     * 标签或词汇术语的名称
     */
    name?: string;
    /**
     * 标签来自标签还是词汇表
     */
    source: TagSource;
    /**
     * 'Suggested'状态在用户或工具建议标签标签时使用。实体的所有者必须在将其标记为'Confirmed'之前确认建议的标签
     */
    state:  State;
    style?: Style;
    tagFQN: string;
}

/**
 *
 * 标签类型描述标签标签是如何应用的，'Manual'表示标签标签是由人员应用的。'Derived'表示使用关联的标签关系导出了标签标签（有关详细信息，请参见Classification.json）。'Propagated`表示标签标签是根据血统从上游传播的。'Automated'在使用工具确定标签标签时使用。
 */
export enum LabelType {
    Automated = "Automated",
    Derived = "Derived",
    Manual = "Manual",
    Propagated = "Propagated",
}

/**
 * 标签来自标签还是词汇表
 */
export enum TagSource {
    Classification = "Classification",
    Glossary = "Glossary",
}

/**
 * 'Suggested'状态在用户或工具建议标签标签时使用。实体的所有者必须在将其标记为'Confirmed'之前确认建议的标签
 */
export enum State {
    Confirmed = "Confirmed",
    Suggested = "Suggested",
}

/**
 * UI Style is used to associate a color code and/or icon to entity to customize the look of
 * that entity in UI.
 */
export interface Style {
    /**
     * Hex Color Code to mark an entity such as GlossaryTerm, Tag, Domain or Data Product.
     */
    color?: string;
    /**
     * An icon to associate with GlossaryTerm, Tag, Domain or Data Product.
     */
    iconURL?: string;
}

/**
 * Life Cycle of the entity
 *
 * 此模式定义生命周期属性
 */
export interface LifeCycle {
    /**
     * 关于数据资产访问方面的访问详细信息
     */
    accessed?: AccessDetails;
    /**
     * 关于数据资产创建方面的访问详细信息
     */
    created?: AccessDetails;
    /**
     * 关于数据资产更新方面的访问详细信息
     */
    updated?: AccessDetails;
}

/**
 * 关于数据资产访问方面的访问详细信息
 *
 * 实体的访问详细信息
 *
 * 关于数据资产创建方面的访问详细信息
 *
 * 关于数据资产更新方面的访问详细信息
 */
export interface AccessDetails {
    /**
     * 创建、更新或访问数据资产的用户、流水线或查询
     */
    accessedBy?: EntityReference;
    /**
     * 访问数据资产的任何未在 OpenMetadata 中捕获的过程
     */
    accessedByAProcess?: string;
    /**
     * 数据资产创建、更新或读取的时间戳
     */
    timestamp: number;
}

/**
 * 创建、更新或访问数据资产的用户、流水线或查询
 *
 * This schema defines the EntityReference type used for referencing an entity.
 * EntityReference is used for capturing relationships from one entity to another. For
 * example, a table has an attribute called database of type EntityReference that captures
 * the relationship of a table `belongs to a` database.
 *
 * Owner of this SearchIndex
 */
export interface EntityReference {
    /**
     * If true the entity referred to has been soft-deleted.
     */
    deleted?: boolean;
    /**
     * Optional description of entity.
     */
    description?: string;
    /**
     * Display Name that identifies this entity.
     */
    displayName?: string;
    /**
     * Fully qualified name of the entity instance. For entities such as tables, databases
     * fullyQualifiedName is returned in this field. For entities that don't have name hierarchy
     * such as `user` and `team` this will be same as the `name` field.
     */
    fullyQualifiedName?: string;
    /**
     * Link to the entity resource.
     */
    href?: string;
    /**
     * Unique identifier that identifies an entity instance.
     */
    id: string;
    /**
     * If true the relationship indicated by this entity reference is inherited from the parent
     * entity.
     */
    inherited?: boolean;
    /**
     * Name of the entity instance.
     */
    name?: string;
    /**
     * Entity type/class name - Examples: `database`, `table`, `metrics`, `databaseService`,
     * `dashboardService`...
     */
    type: string;
}

/**
 * 此模式定义了用于使用标签标记实体的标签类型
 */
export interface CreateSearchIndexTag {
    /**
     * 标签标签的描述
     */
    description?: string;
    /**
     * 标识此标签的显示名称
     */
    displayName?: string;
    /**
     * 到标签资源的链接
     */
    href?: string;
    /**
     *
     * 标签类型描述标签标签是如何应用的，'Manual'表示标签标签是由人员应用的。'Derived'表示使用关联的标签关系导出了标签标签（有关详细信息，请参见Classification.json）。'Propagated`表示标签标签是根据血统从上游传播的。'Automated'在使用工具确定标签标签时使用。
     */
    labelType: LabelType;
    /**
     * 标签或词汇术语的名称
     */
    name?: string;
    /**
     * 标签来自标签还是词汇表
     */
    source: TagSource;
    /**
     * 'Suggested'状态在用户或工具建议标签标签时使用。实体的所有者必须在将其标记为'Confirmed'之前确认建议的标签
     */
    state:  State;
    style?: Style;
    tagFQN: string;
}
